package com.cskaoyan.bean.mini_program_coupon;
/*
 * @author 魏骏杰
 */

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class CouponVO {
    private Integer id;
    private Integer cid;
    private String name;
    private String desc;
    private String tag;
    private Integer min;
    private Integer discount;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date endTime;
    private Integer days;
    private Boolean available;

    public static CouponVO getCouponVO(CouponPOJO couponPOJO) {
        CouponVO couponVO = new CouponVO();
        if (couponPOJO.getId() != null) couponVO.setId(couponPOJO.getId());
        if (couponPOJO.getCoupon_id() != null) couponVO.setCid(couponPOJO.getCoupon_id());
        if (couponPOJO.getName() != null) couponVO.setName(couponPOJO.getName());
        if (couponPOJO.getDesc() != null) couponVO.setDesc(couponPOJO.getDesc());
        if (couponPOJO.getTag() != null) couponVO.setTag(couponPOJO.getTag());
        if (couponPOJO.getMin() != null) couponVO.setMin(couponPOJO.getMin());
        if (couponPOJO.getDiscount() != null) couponVO.setDiscount(couponPOJO.getDiscount());
        if (couponPOJO.getStart_time() != null) couponVO.setStartTime(couponPOJO.getStart_time());
        if (couponPOJO.getEnd_time() != null) couponVO.setEndTime(couponPOJO.getEnd_time());
        if (couponPOJO.getLimit() != null) couponVO.setAvailable(couponPOJO.getLimit() == 0);
        if (couponPOJO.getDays() != null) couponVO.setDays(couponPOJO.getDays());
        return couponVO;
    }
}
